package org.hank.compose_yyzs

import com.google.gson.Gson
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.runBlocking
import org.junit.Test

import org.junit.Assert.*

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }

    @Test
    fun MyMain() {
        var temp = "testest"
        println(temp)
    }

    @Test
    fun flowTest() {
        runBlocking {
            (1..5).asFlow().map {
                check(it != 3) {
                    "Value $it"
                }
                it * it
            }.catch {
                println("enter oncatch $it")
            }.onCompletion {
                println("enter completion========")
            }.collect {
                println("enter collect $it=========")
            }
        }
    }

    @Test
    fun jsonTest(){
        var strArray = mutableListOf("123123","312321","44444")
        println("array format = \"${Gson().toJson(strArray)}\"")
    }
}